package org.thomias.exo6.monitor;

import org.eclipse.jface.action.Action;
import org.eclipse.swt.widgets.TableItem;
import org.thomias.loggertest.YT;

public class CancelAction extends Action {
	private Application app;

	public CancelAction(Application app) {
		this.app = app;
		setText("Cancel");
		setToolTipText("Cancel task");
	}

	@Override
	public void run() {
		YT.debug("Cancel");
		for (TableItem item : app.table.getSelection()) {
			Task task = (Task) item.getData();
			app.m.map.get(task).future.cancel(true);
			app.m.showProgress(task);
		}
	}
}
